/*
Kakine
ActionScript Framework
Copyright © 2011, PUNY, LLC.

This file is part of KAKINE.

KAKINE is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

KAKINE is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with KAKINE.  If not, see <http://www.gnu.org/licenses/>.
*/ 
package com.puny.ball.utils.handlers
{
	import com.puny.ball.utils.Vector2D;
	import com.puny.utils.easing.IEasing;
	
	import flash.geom.Point;
	
	internal class MovingHandler extends Object
	{
		private var _easing:IEasing;
		private const _org:Point = new Point();
		private const _v:Vector2D = new Vector2D();
		private var _random:Boolean = true;

		public function MovingHandler() {
		}
		
		protected function set easing(value:IEasing):void {
			_easing = value;
		}
		
		protected function get easing():IEasing {
			return _easing;
		}

		protected function noise(sw:Boolean):Number {
//			trace("noise sw=", sw);
			if (_random && sw) {
//				return Random.sign()*2;
				return 2;
			}
			return 0;
		}

		public function set random(value:Boolean):void {
			_random = value;
		}

		public function get random():Boolean {
			return _random;
		}
		
		public function noisedVx(sw:Boolean):Number {
			return v.x + noise(v.x == 0 && sw);
		}
		
		public function noisedVy(sw:Boolean):Number {
//			trace("v.y=",v.y);
			return v.y + noise(v.y == 0 && sw);
		}
		
		public function get org():Point {
			return _org;
		}
		
		public function get v():Vector2D {
			return _v;
		}
		
	}
}